// [[ OnflowGenerator File UUID: eccd975a09414557918c5341b10f727d  ]]
package com.itdct.onflow.system.account.controller

import com.itdct.onflow.core.annotation.ApiParam
import com.itdct.onflow.core.type.*
import com.itdct.onflow.core.vo.KeyLabelValueVo
import com.itdct.onflow.core.vo.RespPageVo
import com.itdct.onflow.core.vo.RespVo
import com.itdct.onflow.system.account.qo.*
import com.itdct.onflow.system.account.service.SysAccountService
import com.itdct.onflow.system.account.vo.SysAccountDetailVo
import com.itdct.onflow.system.account.vo.SysAccountListVo
import com.itdct.onflow.system.account.vo.SysAccountLoginVo
import com.itdct.onflow.system.account.vo.SysAccountMyInfoVo
import com.itdct.onflow.system.common.base.BaseSysController
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.tags.Tag
import org.springframework.http.MediaType
import org.springframework.validation.annotation.Validated
import org.springframework.web.bind.annotation.*

/**
 * @author DCTANT
 * @date 2025-09-01 15:11:24
 * @version 1.0
 * @description 系统账户接口控制
 */
@Tag(name = SysAccountController.moduleName)
@RestController
@RequestMapping(value = ["/sysAccount"], produces = [MediaType.APPLICATION_JSON_VALUE], method = [RequestMethod.POST])
class SysAccountController(
    val sysAccountService: SysAccountService
) : BaseSysController() {
    companion object {
        const val moduleName = "系统账户"
    }

    @ApiParam(important = true)
    @Operation(summary = moduleName + "添加")
    @PostMapping("/add.adw")
    fun add(@RequestBody @Validated(Add::class) qo: SysAccountEditQo): RespVo<Long> {
        return sysAccountService.add(qo, getContext())
    }

    @ApiParam(important = true)
    @Operation(summary = moduleName + "更新")
    @PostMapping("/update.adw")
    fun update(@RequestBody @Validated(Update::class) qo: SysAccountEditQo): RespVo<Unit> {
        return sysAccountService.update(qo, getContext())
    }

    @ApiParam(important = true)
    @Operation(summary = moduleName + "删除")
    @PostMapping("/delete.adw")
    fun delete(@RequestBody @Validated(Delete::class) qo: SysAccountEditQo): RespVo<Unit> {
        return sysAccountService.delete(qo, getContext())
    }

    @Operation(summary = moduleName + "详情")
    @PostMapping("/detail.adw")
    fun detail(@RequestBody @Validated(Detail::class) qo: SysAccountSearchQo): RespVo<SysAccountDetailVo> {
        return sysAccountService.detail(qo, getContext())
    }

    @Operation(summary = moduleName + "列表")
    @PostMapping("/page.adw")
    fun page(@RequestBody @Validated(Page::class) qo: SysAccountSearchQo): RespPageVo<SysAccountListVo> {
        return sysAccountService.page(qo, getContext())
    }

    @ApiParam(important = true)
    @Operation(summary = moduleName + "登录")
    @PostMapping("/login.adw")
    fun login(@RequestBody qo: SysAccountLoginQo): RespVo<SysAccountLoginVo> {
        return sysAccountService.login(qo, getContext())
    }

    @ApiParam(important = true)
    @Operation(summary = moduleName + "登出")
    @PostMapping("/logout.adw")
    fun logout(): RespVo<SysAccountLoginVo> {
        return sysAccountService.logout(getContext())
    }

    @Operation(summary = moduleName + "用户个人信息")
    @PostMapping("/getMyInfo.adw")
    fun getMyInfo(): RespVo<SysAccountMyInfoVo> {
        return sysAccountService.getMyInfo(getContext())
    }

    @ApiParam(important = true)
    @Operation(summary = moduleName + "更新")
    @PostMapping("/updateMyInfo.adw")
    fun updateMyInfo(@RequestBody @Validated(Update::class) qo: SysAccountMyInfoQo): RespVo<Unit> {
        return sysAccountService.updateMyInfo(qo, getContext())
    }

    @ApiParam(important = true)
    @Operation(summary = moduleName + "更新个人密码")
    @PostMapping("/updatePassword.adw")
    fun updatePassword(@RequestBody @Validated qo: SysAccountUpdatePasswordQo): RespVo<Unit> {
        return sysAccountService.updatePassword(qo, getContext())
    }

    // [[ OnflowGenerator Range (- selectFunctions -) Start ]]
    @Operation(summary = moduleName + "账户名下拉选")
    @PostMapping("/selectNameList.adw")
    fun selectNameList(@RequestBody qo: SysAccountSearchQo): RespVo<List<KeyLabelValueVo>> {
        return sysAccountService.selectNameList(qo, getContext())
    }

// [[ OnflowGenerator Range (- selectFunctions -) End ]]
}